<!--  ajax axios  -->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>测试热门商品数据</title>
</head>

<body>
    <div id="app">
        <ul>
            <li v-for="k in hotList" :key="k.id">

                <div><img :src="k.img" alt=""></div>
                <p>{{k.title}}</p>
                <p>{{k.sellPrice}}</p>
            </li>
        </ul>
    </div>
</body>

</html>
<script src="./vue2.js"></script>
<script src="./axios.js"></script>
<script>
    new Vue({
        el: "#app",
        data() {
            return {
                hotList: []
            }
        },
        created() {
            // 一打开页面这个钩子函数就会被执行
            axios.get('http://127.0.0.1:3006/home/hotshop', {
                params: {
                    page: 0,
                    count: 10
                }
            }).then((res) => {
                console.log(res.data.result);
                this.hotList = res.data.result;
            })
        }
    })
</script>